package com.viser.partyinrs.listadapters;

import java.util.ArrayList;


import com.viser.partyinrs.R;
import com.viser.partyinrs.entities.Mesto;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MestaListAdapter extends BaseAdapter {

	//adapter za listu mesta za izlaske
	
	ArrayList<Mesto> mesta;
	Activity context;
	
	
	public MestaListAdapter(ArrayList<Mesto> mesta, Activity context) {
		super();
		this.mesta = mesta;
		this.context = context;
	}

	@Override
	public int getCount() {
		return mesta.size();
	}

	@Override
	public Object getItem(int position) {
		return mesta.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View layout = inflater.inflate(R.layout.mesto_item, parent, false);
		
		TextView txtMesto = (TextView) layout.findViewById(R.id.txtMesto);
		TextView txtMestoVreme = (TextView) layout.findViewById(R.id.txtMestoVreme);
		
		
		txtMesto.setText(((Mesto)getItem(position)).naziv);
		txtMestoVreme.setText("Radno vreme: " + ((Mesto)getItem(position)).radi_od + " - " +((Mesto)getItem(position)).radi_do);
		
		return layout;
	}

}
